home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / archiver / lzhsourc.lzh / LZH.SRC / TEST_AFX.S < prev    next >
Text File  |  1992-07-02  |  4KB  |  136 lines

  1. debug           EQU 0
  2. _onoff          EQU 8
  3.  
  4.     export test_afx
  5.  
  6. ; Modul testet, ob eine Datei mit AFX gepackt ist oder werden darf.
  7. test_afx:       movem.l D1-a6,-(SP)
  8.                 moveq   #0,D0
  9.                 bsr     afxonoff        ; AFX ausschalten
  10.                 move.l  D0,-(SP)        ; Alten Zustand merken
  11.  
  12.                 movea.l A0,A4
  13.                 pea     1026.w
  14.                 move.w  #$48,-(SP)      ; Malloc
  15.                 trap    #1
  16.                 addq.l  #6,SP
  17.                 addq.l  #1,D0
  18.                 and.b   #$FE,D0         ; auf gerade Adresse
  19.                 movea.l D0,A5           ; 1k Speicher
  20.  
  21.  
  22.                 clr.w   -(SP)
  23.                 move.l  A4,-(SP)        ; filename
  24.                 move.w  #$3D,-(SP)      ; fopen
  25.                 trap    #1
  26.                 addq.l  #8,SP
  27.                 tst.l   D0
  28.                 bmi.b   unpacked        ; micht gefunden
  29.                 move.l  D0,D3           ; Handle
  30.                 move.l  A5,-(SP)
  31.                 pea     1024.w
  32.                 move.w  D3,-(SP)        ; handle
  33.                 move.w  #$3F,-(SP)      ; fread
  34.                 trap    #1
  35.                 lea     12(SP),SP
  36.  
  37.                 move.w  D3,-(SP)
  38.                 move.w  #$3E,-(SP)      ; close
  39.                 trap    #1
  40.                 addq.l  #4,SP
  41.  
  42. ; A5 zeigt auf die ersten 1KB des Files. teste nun auf Programm und auf
  43. ; AFX.
  44.                 cmpi.w  #$601A,(A5)
  45.                 beq.b   is_prg          ; Ist eine Programmdatei
  46.  
  47.                 movea.l A5,A0
  48.                 moveq   #0,D0
  49.                 moveq   #0,D1
  50.                 moveq   #0,D2
  51.                 move.b  (A0)+,D1
  52.                 move.b  (A0)+,D2
  53.                 subq.w  #1,D1
  54. get_chk:        add.b   (A0)+,D0
  55.                 dbra    D1,get_chk
  56.                 cmp.b   D0,D2
  57.                 seq     D0              ; D0 = 0: Checksum stimmt nicht
  58.                 bne.b   unpacked        ; Stimmt nicht: Ungepackt
  59.                 cmpi.l  #'-afx',2(A5)
  60.                 beq.b   is_afx          ; Kein AFX
  61.                 cmpi.w  #'-l',2(a5)
  62.                 bne.b   unpacked
  63.                 cmpi.b  #'-',6(a5)
  64.                 beq.b    is_lzh
  65.  
  66. unpacked:       moveq   #0,D3
  67.                 bra.b   testx
  68. is_afx:         moveq   #1,D3
  69.                 bra.b   testx
  70. is_lzh:         moveq   #2,D3
  71.                 bra.b   testx
  72. is_prg:         moveq   #3,D3
  73.  
  74. testx:          move.l  A5,-(SP)
  75.                 move.w  #$49,-(SP)      ; Mfree
  76.                 trap    #1
  77.                 addq.l  #6,SP
  78.  
  79.                 move.l  (SP)+,D0        ; Alter Status
  80.                 bsr.b   afxonoff        ; wiederherstellen
  81.                 move.l  D3,D0
  82.                 movem.l (SP)+,D1-a6
  83.  
  84.                 rts
  85.  
  86.  
  87.  
  88. afxonoff:       movem.l D1-A6,-(SP)
  89.                 bsr.b   find_afx
  90.                 cmpa.l  #0,A4
  91.                 beq.b   onofX
  92.                 move.l  _onoff(A4),D1
  93.                 move.l  D0,_onoff(A4)
  94.                 move.l  D1,D0
  95. onofX:          movem.l (SP)+,D1-A6
  96.                 rts
  97.  
  98.  
  99.  
  100.  
  101. find_afx:       move.l  D0,-(SP)
  102.                 clr.l   -(SP)           ; stck
  103.                 move.w  #$20,-(SP)      ; super
  104.                 trap    #1
  105.                 addq.l  #6,SP
  106.                 move.l  D0,-(SP)
  107.                 move.w  #$20,-(SP)      ; super
  108.                 movea.l $84,A4
  109. find_afx1:      cmpi.l  #'XBRA',-12(A4)
  110.                 bne.b   no_afx
  111.                 cmpi.l  #'AFX ',-8(A4)
  112.                 beq.b   found_afx
  113.                 movea.l -4(A4),A4
  114.                 bra.b   find_afx1
  115. no_afx:         trap    #1
  116.                 addq.l  #6,SP
  117.                 suba.l  A4,A4
  118.                 move.l  (SP)+,D0
  119.                 rts
  120. found_afx:      lea     -16(A4),A4
  121.                 move.l  (A4),D0
  122.                 lea     0(A4,D0.w),A4
  123.                 cmpi.l  #'PARX',-4(A4)
  124.                 bne.b   no_afx
  125.                 trap    #1
  126.                 addq.l  #6,SP
  127.                 move.l  (SP)+,D0
  128.                 rts
  129.  
  130.                 IF debug
  131. filename:
  132. ;                DC.B 'C:\SYSTEM\MISHELL.PRG',0
  133.                 DC.B 'E:\TEX\MISHELL\MB.TEX',0
  134.                 ENDC
  135.                 END
  136.